<?php

class wms_finder_spadjustmentdoc
{

	var $column_edit = '操作';
	var $column_edit_width = "50";

    var $detail_spadjustmentdoc_line = "调整明细条件";
	public function column_edit($row)
	{
		$finder_id = $_GET['_finder']['finder_id'];

        $stockappMdl = app::get('wms')->model('spadjustmentdoc');
        $stockapp_datas= $stockappMdl->dump($row['id'],'status');
        if($stockapp_datas['status']=='unconfirmed')
        {
            return '<a href="index.php?app=wms&ctl=admin_spadjustmentdoc&act=editspadjustmentdoc&id=' . $row['id'] . '&finder_id='.$finder_id.'" target="_blank">编辑</a>';
        }else
        {
            return '';
        }
	}

    function detail_spadjustmentdoc_line($row){
        $render = app::get('wms')->render();
        //$sql="SELECT * from sdb_wms_spadjustmentdoc_line where spadjustmentdoc_id=".$row;
        $sql="SELECT id,spadjustmentdoc_id,bn,product_name,price,diffprice,cod,FROM_UNIXTIME(last_modify, '%Y-%m-%d %H:%i:%S') as last_modify,FROM_UNIXTIME(begin_date, '%Y-%m-%d') as begin_date,FROM_UNIXTIME(end_date, '%Y-%m-%d') as end_date from sdb_wms_spadjustmentdoc_line where spadjustmentdoc_id=".$row;
        
        $db=kernel::database();
        $basicMaterialInfo=$db->select($sql);   
        $render->pagedata['res'] = $basicMaterialInfo;
        return $render->fetch('admin/spadjustmentdoc/spdoc_line.html');
    }

    var $detail_spadjustmentdoc_record = "调整明细记录";
    function detail_spadjustmentdoc_record($row){
        $render = app::get('wms')->render();
        //$sql="SELECT * from sdb_wms_spadjustmentdoc_record where spadjustmentdoc_id=".$row;
        $sql="SELECT id,spadjustmentdoc_id,order_bn,createtime,bn,`name`,unit,nums,price,divide_order_fee,diffmny,diffprice,FROM_UNIXTIME(last_modify, '%Y-%m-%d %H:%i:%S') as last_modify,FROM_UNIXTIME(begin_date, '%Y-%m-%d') as begin_date,FROM_UNIXTIME(end_date, '%Y-%m-%d') as end_date from sdb_wms_spadjustmentdoc_record where spadjustmentdoc_id=".$row;
        
        $db=kernel::database();
        $basicMaterialInfo=$db->select($sql);   
        foreach ($basicMaterialInfo as $key => $value) 
        {
            $basicMaterialInfo[$key]['createtime']=Date('Y-m-d h:i:s',$value['createtime']);

            $basicMaterialInfo[$key]['nums']=floatval($value['nums']);
        }
        $render->pagedata['res'] = $basicMaterialInfo;
        return $render->fetch('admin/spadjustmentdoc/spdoc_record.html');
    }
}